<?php
class Syscfg extends AdminAction{
	function index(){
		
		$db=$this->getDB(); 
		$cfglist = $db->query_assoc("select * from syscfg where lang = '$this->lang'");
		$this->data['cfglist'] = $cfglist;
		template('syscfg',$this->data);
	}
	
	function cfgupdate(){
		$db=$this->getDB(); 
		$cfglist = $db->query_assoc("select * from syscfg where lang = '$this->lang'");
		
		foreach ($cfglist as $cfg){
			$ck = $cfg['skey'];
			$pv = P("$ck");
			$id = $cfg['id'];
			if($pv&&$pv!=""){
				$db->query("update syscfg set svalue = '$pv' where id = $id");
			}
		}
		
		$syscfg = $db->query_assoc("select * from syscfg where lang = '$this->lang'");
		$syscfglist = array();
		foreach ($syscfg as $cfg){
			$syscfglist[$cfg['skey']] = $cfg['svalue'];
		}
		$filestr = '<?php return ' . var_export($syscfglist, true) . '; ?>';
		saveDataFile('syscfg',$this->lang,$filestr);
		
		message('系统信息编辑成功！', '/admin.php/syscfg/index');
	}
}